import request from '@/utils/request.js'

export function getArticleList (params) {
  return request({
    url: '/v1_1/articles',
    params
  })
}

export function getAllChannel () {
  return request({
    url: '/v1_0/channels'

  })
}

export function getArticleDetail (id) {
  return request({
    url: '/v1_0/articles/' + id

  })
}

/**
 * 收藏
 * @param {*} target 文章id
 */
export function addCollectArticle (target) {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target
    }

  })
}

/**
 * 取消收藏
 * @param {*} target 文章id
 */
export function deleteCollectArticle (target) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}

export function getCommentList (params) {
  return request({
    url: '/v1_0/comments',
    method: 'get',
    params
  })
}

/**
 * 发布评论
 * @param {*} data {文章id 评论内容 对内容的评论id}
 */
export function getComment (data) {
  return request({
    url: '/v1_0/comments',
    method: 'post',
    data
  })
}
